package net.adetech.dcweb.core.dc.rest;

import net.adetech.dcweb.core.dc.service.IDcDataService;
import net.adetech.web.utils.UtilsUI;
import net.adetech.web.utils.UtilsWeb;
import net.adetech.web.utils.spring.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by auto on 2016/10/21.
 */
@RestController
public class DcDataRestController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(DcDataRestController.class);

    @Autowired
    private IDcDataService iDcDataService;


    @PostMapping(value = "/dc/data", produces = "application/json")
    public String add(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String xml = UtilsWeb.getString(request, "xml", false);
        iDcDataService.save(xml);
        return UtilsUI.ok();
    }

}